#include<bits/stdc++.h>
#define int __int128
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
int n,m,cnt;
int t[2410],w[2410],cc[110],tt[110],ww[110],tot;
int f[10010];
void write(int x)
{
	if(x==0)return;
	write(x/10);
	cout << (long long)(x%10);
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	long long read;
	cin >>read;
	n=read;
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin>> read;cc[i]=read;
	}
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin>> read;tt[i]=read;
	}
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin>> read;ww[i]=read;
		cnt+=tt[i]*cc[i];
	}
	cin >> read;
	m=read;
//	m=min(m,cnt);
	for ( int i = 1 ; i <= n ; i++ )
	{
		for ( int j = 0 ; (1<<j) <= cc[i] ; j++ )
		{
			tot++;
			t[tot]=(1<<j)*tt[i];
			w[tot]=(1<<j)*ww[i];
			cc[i]-=(1<<j);
		}
		if(cc[i])
		{
			tot++;
			t[tot]=cc[i]*tt[i];
			w[tot]=cc[i]*ww[i];
		}
	}
	for ( int i = 1 ; i <= tot ; i++ )
	{
		for ( int j = m ; j >= t[i] ; j-- )f[j]=max(f[j],f[j-t[i]]+w[i]);
	}
	int ans=0;
	for ( int i = 1 ; i <= m ; i++ )ans=max(ans,f[i]);
	if(ans==0)return cout << 0,0;
	write(ans);
//	cout << ans;
	return 0;
}//40 
